-
Notifications
You must be signed in to change notification settings - Fork 873
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix directory separator in ProcessResource attributes #6716
Fix directory separator in ProcessResource attributes #6716
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thx @fcrespel! can you see if it's not too hard to add a test for this?
Note that this issue was already present in sdk-extensions-resources before it was moved here; should it be fixed there too?
cc @jack-berg
@trask I updated the existing tests in ProcessResourceTest to include the directory separator, is that OK for you? |
@@ -29,7 +30,7 @@ void notWindows() { | |||
|
|||
assertThat(attributes.get(ResourceAttributes.PROCESS_PID)).isGreaterThan(1); | |||
assertThat(attributes.get(ResourceAttributes.PROCESS_EXECUTABLE_PATH)) | |||
.contains("java") | |||
.contains(File.separatorChar + "java") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe something like .matches("[/\\]java")
? e.g. to avoid the test verification relying on the same logic that we missed previously
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated the tests accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thx @fcrespel1
…#6716) The separator char used to build the Java executable path in ProcessResource is wrong: `File.pathSeparatorChar` is the PATH variable separator (`:` on Linux, `;` on Windows), the right one for directories is `File.separatorChar` (`/` on Linux, `\` on Windows). Note that this issue was already present in [sdk-extensions-resources](https://github.com/open-telemetry/opentelemetry-java/blob/main/sdk-extensions/resources/src/main/java/io/opentelemetry/sdk/extension/resources/ProcessResource.java#L64) before it was moved here; should it be fixed there too?
…#6716) The separator char used to build the Java executable path in ProcessResource is wrong: `File.pathSeparatorChar` is the PATH variable separator (`:` on Linux, `;` on Windows), the right one for directories is `File.separatorChar` (`/` on Linux, `\` on Windows). Note that this issue was already present in [sdk-extensions-resources](https://github.com/open-telemetry/opentelemetry-java/blob/main/sdk-extensions/resources/src/main/java/io/opentelemetry/sdk/extension/resources/ProcessResource.java#L64) before it was moved here; should it be fixed there too?
…#6716) The separator char used to build the Java executable path in ProcessResource is wrong: `File.pathSeparatorChar` is the PATH variable separator (`:` on Linux, `;` on Windows), the right one for directories is `File.separatorChar` (`/` on Linux, `\` on Windows). Note that this issue was already present in [sdk-extensions-resources](https://github.com/open-telemetry/opentelemetry-java/blob/main/sdk-extensions/resources/src/main/java/io/opentelemetry/sdk/extension/resources/ProcessResource.java#L64) before it was moved here; should it be fixed there too?
The separator char used to build the Java executable path in ProcessResource is wrong:
File.pathSeparatorChar
is the PATH variable separator (:
on Linux,;
on Windows), the right one for directories isFile.separatorChar
(/
on Linux,\
on Windows).Note that this issue was already present in sdk-extensions-resources before it was moved here; should it be fixed there too?